/*
Problem Description
读入一个只包含 +, -, *, / 的非负整数计算表达式，计算该表达式的值。
 
Input
测试输入包含若干测试用例，每个测试用例占一行，每行不超过200个字符，整数和运算符之间用一个空格分隔。
没有非法表达式。当一行中只有0时输入结束，相应的结果不要输出。
 
Output
对每个测试用例输出1行，即该表达式的值，精确到小数点后2位。

Sample Input
1 + 2
4 + 2 * 5 - 7 / 11
0

Sample Output
3.00
13.36
 */
package com.yuan.algorithms.team20150724;

import java.util.Scanner;

/**
 * @author YouYuan E-mail:1265161633@qq.com
 * @version 创建时间：2015年7月30日 上午10:18:55 说明:
 */
class Stack {
	private int top;
	private Object[] element;
	private int SIZE = 20;

	public Stack() {
		top = -1;
		element = new Object[SIZE];
	}

	public void push(Object e) {
		if (top == SIZE - 1) {
			expandSpace();
		}
		element[++top] = e;
	}

	private void expandSpace() {
		SIZE <<= 1;
		Object[] newData = new Object[SIZE];
		for (int i = 0, len = element.length; i < len; i++) {
			newData[i] = element[i];
		}
		element = newData;
	}

	public Object peek() {
		if (isEmpty()) {
			throw new RuntimeException("错误，堆栈为空。");
		}
		return element[top];
	}

	public Object pop() {
		if (isEmpty()) {
			throw new RuntimeException("错误，堆栈为空。");
		}
		Object t = element[top];
		element[top--] = null;
		return t;
	}

	public boolean isEmpty() {
		return top < 0;
	}
}

public class 堆栈_简单计算器 {

	static Stack operator = new Stack();
	static Stack num = new Stack();

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str;
		while (!(str = sc.nextLine()).equals("0")) {
			disposeExpression(str);
			double result = operation();
			System.out.printf("%.2f", result);
			System.out.println();
		}
	}

	private static double operation() {
		while (!operator.isEmpty()) {
			count();
		}
		return (double) num.pop();
	}

	private static void disposeExpression(String str) {
		String[] data = str.split(" ");
		for (int i = 0, len = data.length; i < len; i++) {
			char t = data[i].charAt(0);
			if (t >= '0' && t <= '9') {
				num.push(Double.parseDouble(data[i]));
			} else {
				if (operator.isEmpty()) {
					operator.push(data[i]);
				} else {
					while (!operator.isEmpty()) {
						if (getPriority(data[i]) < getPriority(operator.peek())) {
							operator.push(data[i]);
							break;
						} else {
							count();
							if (operator.isEmpty()) {
								operator.push(data[i]);
								break;
							}
						}

					}
				}
			}
		}
	}

	private static void count() {
		double a, b;
		double rs = 0;
		b = (double) num.pop();
		a = (double) num.pop();
		String s = (String) operator.pop();
		switch (s) {
		case "+":
			rs = a + b;
			break;
		case "-":
			rs = a - b;
			break;
		case "*":
			rs = a * b;
			break;
		case "/":
			rs = a / b;
			break;
		}
		num.push(rs);
	}

	private static int getPriority(Object peek) {
		int priority = 2;
		String t = (String) peek;
		switch (t) {
		case "+":
		case "-":
			priority = 2;
			break;
		case "*":
		case "/":
			priority = 1;
			break;
		}
		return priority;
	}

}
